<title>Zipcode</title>
<div id="view-content">
    <div class="row-fluid">
        <div class="span10">
            <div class="well span4">
                <?php if ($this->formErrors != null) { ?>
                    <div class="alert alert-error">
                        <button type="button" class="close" data-dismiss="alert">&times;</button>
                        <?= $this->formErrors[0] ?>
                    </div>
                <?php } ?>
                <?= $this->form ?>
            </div>
            <div class="well span8">
                <table class="table">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Zipcode</th>
                            <th>City</th>
                            <th>State</th>
                            <th></th>
                        </tr>
                    </thead>
                    <?php
                    $index = 1;
                    foreach ($this->allZip as $zip) :
                        ?>
                        <tr>
                            <td><?= $index ?></td>
                            <td><?= $zip['codes'] ?></td>
                            <td><?php
                                $cityId = $zip['city_id'] - 1;
                                $stateId = 0;
                                $cityName = '';
                                if ($cityId != -1) {
                                    $cityName = $this->allCity[$cityId]['name'];
                                    $stateId = $this->allCity[$cityId]['state_id'];
                                }
                                echo $cityName;
                                ?></td>
                            <td>
                                <?php
                                $stateNames = '';
                                if ($stateId != 0) {
                                    $stateDb = new Ads_Model_State();
                                    $stateById = $stateDb->getStateById($stateId);
                                    $stateNames = $stateById[0]['name'];
                                    echo $stateNames;
                                }
                                ?>
                            </td>
                            <td><a class="btn btn-small" href="<?= $this->url(array('id' => $zip['id']), 'zip-update'); ?>"><i class="icon-edit"></i> Edit</a></td>
                        </tr>
                        <?php
                        $index++;
                    endforeach;
                    ?>
                </table>
            </div>
        </div>
    </div>
</div>